package com.atguigu.ggkt.order.api;

import com.atguigu.ggkt.model.order.OrderInfo;
import com.atguigu.ggkt.order.service.OrderInfoService;
import com.atguigu.ggkt.result.Result;
import com.atguigu.ggkt.vo.order.OrderFormVo;
import com.atguigu.ggkt.vo.order.OrderInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/order/orderInfo")//编写创建订单接口
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

   //生成订单方法
   @PostMapping("submitOrder")
    public Result submitOrder(@RequestBody OrderFormVo orderFormVo){
       //订单id
       Long orderId =  orderInfoService.submitOrder(orderFormVo);
       return Result.ok(orderId);
   }

   //获取订单信息方法
    @ApiOperation(value = "获取")
    @GetMapping("getInfo/{id}")
    public Result getInfo(@PathVariable Long id){
       OrderInfoVo orderInfoVo = orderInfoService.getOrderInfoById(id);
       return Result.ok(orderInfoVo);
    }


}